<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         * 定义一个JSON对象，表示用户
         */ 
        var user = {
            "id": 1001,
            "name": "tom",
            "age": 19,
            "height": 190.4,
            "address": {
                "province": "江苏省",
                "city": "南京",
                "street": "秦淮区"

            }
        }

        console.log(user)
        console.log(user.name, user.age)
        console.log(user.address.city)

        var users = [
            {
                "id" : 1,
                "username": "admin", 
                "password": "123456",
                "status": 1
            },
            {
                "id" : 2,
                "username": "tom", 
                "password": "123456",
                "status": 1
            },
            {
                "id" : 3,
                "username": "jerry", 
                "password": "123456",
                "status": 0
            }
        ]

        // for(var u of users){
        //     console.log(u)
        // }

        /**
         *  JSON和字符串之间的转换
         */ 
        // JSON转换为字符串
        // console.log(typeof user) // object

        // var s = JSON.stringify(user) 
        // console.log(typeof s) // string
        // console.log(s)

        // 字符串转换为JSON
        // var s = '{"name":"tom", "age":19, "sex": "男"}'
        // console.log(typeof s)
        // var obj = JSON.parse(s)
        // console.log(obj)
        // console.log(obj.age)


            




    </script>
</head>
<body>
    
</body>
</html>